import { S } from '../../s';
import { IPSAppCounterRef } from '../../app/control/ipsapp-counter-ref';
import { IPSAppView } from '../../app/view/ipsapp-view';
import { IPSAppViewUIAction } from '../../app/view/ipsapp-view-uiaction';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { IPSDEForm } from './ipsdeform';
import { IPSDEFormButton } from './ipsdeform-button';
import { IPSDEFormItemUpdate } from './ipsdeform-item-update';
import { PSDEFormDetailImpl } from './psdeform-detail-impl';
import { IPSUIAction } from '../../view/ipsuiaction';

export class PSDEFormButtonImpl
  extends PSDEFormDetailImpl
  implements IPSDEFormButton
{
  get actionType(): 'UIACTION' | 'FIUPDATE' {
    return this.M.actionType;
  }

  get captionItemName(): string {
    return this.M.captionItemName;
  }

  protected psappcounterref: IPSAppCounterRef;
  getPSAppCounterRef(): IPSAppCounterRef | null {
    return (
      this.psappcounterref ||
      (this.psappcounterref = this.fillObjectModel(
        S._9d,
        this.M.getPSAppCounterRef,
        S._2a9,
      ) as IPSAppCounterRef)
    );
  }

  protected psappviewuiaction: IPSAppViewUIAction;
  getPSAppViewUIAction(): IPSAppViewUIAction | null {
    return (
      this.psappviewuiaction ||
      (this.psappviewuiaction = this.fillObjectModel(
        S._8e,
        this.M.getPSAppViewUIAction,
        S._2da,
      ) as IPSAppViewUIAction)
    );
  }

  protected psdeformitemupdate: IPSDEFormItemUpdate;
  getPSDEFormItemUpdate(): IPSDEFormItemUpdate | null {
    if (this.psdeformitemupdate != null) return this.psdeformitemupdate;
    const value = this.M.getPSDEFormItemUpdate;
    if (value == null) {
      return;
    }
    const ipsdeform = this.getParentPSModelObject(S._23d) as IPSDEForm;
    if (ipsdeform != null) {
      this.psdeformitemupdate = ipsdeform.findPSDEFormItemUpdate(value);
    }
    return this.psdeformitemupdate;
  }

  protected psnavigatecontexts: IPSNavigateContext[];
  getPSNavigateContexts(): IPSNavigateContext[] | null {
    return (
      this.psnavigatecontexts ||
      (this.psnavigatecontexts = this.fillChildListModel(
        this.M.getPSNavigateContexts,
        S._8c,
      ) as IPSNavigateContext[])
    );
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5(
      S._8c,
      this.getPSNavigateContexts(),
      objKey,
    ) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[];
  getPSNavigateParams(): IPSNavigateParam[] | null {
    return (
      this.psnavigateparams ||
      (this.psnavigateparams = this.fillChildListModel(
        this.M.getPSNavigateParams,
        S._8a,
      ) as IPSNavigateParam[])
    );
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5(
      S._8a,
      this.getPSNavigateParams(),
      objKey,
    ) as IPSNavigateParam;
  }

  protected psuiaction: IPSUIAction;
  getPSUIAction(): IPSUIAction | null {
    return (
      this.psuiaction ||
      (this.psuiaction = this.fillObjectModel(
        S._29d,
        this.M.getPSUIAction,
        S._2de,
      ) as IPSUIAction)
    );
  }

  protected parampickuppsappview: IPSAppView;
  getParamPickupPSAppView(): IPSAppView | null {
    return (
      this.parampickuppsappview ||
      (this.parampickuppsappview = this.fillObjectModel(
        S._1e,
        this.M.getParamPickupPSAppView,
        S._2ec,
      ) as IPSAppView)
    );
  }

  get paramViewParamJO(): IModel {
    return this.M.paramViewParamJO;
  }

  get tooltip(): string {
    return this.M.tooltip;
  }

  get uIActionParamJO(): IModel {
    return this.M.uIActionParamJO;
  }

  get uIActionTarget():
    | 'SINGLEDATA'
    | 'SINGLEKEY'
    | 'MULTIDATA'
    | 'MULTIKEY'
    | 'NONE' {
    return this.M.uIActionTarget;
  }

  get xDataControlName(): string {
    return this.M.xDataControlName;
  }

  get saveTargetFirst(): boolean {
    return this.M.saveTargetFirst != null ? this.M.saveTargetFirst : false;
  }
  get cls(): string {
    return 'PSDEFormButtonImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._8e || cls == S._af || cls == S._7 || cls == S._b0)
      return true;
    return super.instanceof(cls);
  }
}
